import java.io.*;
import java.util.*;

public class Test2{
    final static int N = 10010;
    static int fa[] = new int[N * 2];

    public static class Node {
        public int a, b, w;

        public Node(int a, int b, int w) {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

    public static class cmp implements Comparator<Node> {
        @Override
        public int compare(Node o1, Node o2) {
            return o1.w - o2.w;
        }
    }

    public static int Find(int x) {
        while (x != fa[x]) {
            x = fa[x];
        }
        return x;
    }

    static class Solver {
        public void solve(InputReader in, PrintWriter out) {
            int c = in.nextInt();
            int n = in.nextInt();
            int m = in.nextInt();
            List<Node> list = new ArrayList<Node>();
            for (int i = 0; i <= m; i++) {
                fa[i] = i;
            }
            for (int i = 0; i < n; i++) {
                list.add(new Node(in.nextInt(), in.nextInt(), in.nextInt()));
            }
            int sum = 0;
            list.sort(new cmp());
            for (int i = 0; i < n; i++) {
                int x = Find(list.get(i).a);
                int y = Find(list.get(i).b);
                if (x != y) {
                    fa[x] = y;
                    sum += list.get(i).w;
                }
            }
            if (sum <= c) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}
